import { Router } from 'hyper-express';
import handleLogout from '../../../controllers/uctoo/auth/logout';
import handleMe from '../../../controllers/uctoo/auth/me';
import handleSignin from '../../../controllers/uctoo/auth/signin';
import handleSignup from '../../../controllers/uctoo/auth/signup';
import handleResetpassword from '../../../controllers/uctoo/auth/resetpassword';
import handleLogin from '../../../controllers/uctoo/auth/uctooAuth';
import requireUser from '../../../middlewares/auth/requireUser';
import githubRouter from './github';
import googleRouter from './google';
import wechatopenRouter from './wechatopen';

const authRouter = new Router();

authRouter.get('/authcheck', requireUser, async (req, res) => {
  res.send('You are authorized');
});
authRouter.get('/healthcheck', (req, res) => {
  res.status(200).end();
});
authRouter.get('/me', requireUser, handleMe);

authRouter.get('/logout', requireUser, handleLogout); 

authRouter.post('/login', handleLogin);  //无验证码
authRouter.post('/signin', handleSignin);  //根据config带验证码
authRouter.post('/signup', handleSignup);

authRouter.use('/signin/github', githubRouter);
authRouter.use('/signin/google', googleRouter);
authRouter.use('/signin/wechatopen', wechatopenRouter);
authRouter.post('/resetpassword', handleResetpassword);

export default authRouter;
